// 获取资产状态
import { defineStore } from 'pinia'
import { storage } from '../utils'
export default defineStore('assetStatusStore', {
  state: () => ({
    assetStatus: JSON.parse(storage.get('ASSEST_STATUS', '[]')) as any[],
  }),
  actions: {
    loadState() {
      const data = storage.get('ASSEST_STATUS', '[]');
      this.$patch({ assetStatus: JSON.parse(data) });
    },

    setAllState(newState: Partial<any[]>) {
      storage.set('ASSEST_STATUS', JSON.stringify(newState))
      this.$patch({ assetStatus: newState });
    },
    getAllState(): any[] {
      this.loadState();
      return this.assetStatus;
    },
  },
})
